package Work0519;

/**
 * 游戏类
 * 
 * @author Y
 *
 */
public class Game {
	private Player a;// 玩家

	public String printStr(Player a) {
		String str = "";
		for (int i = 0; i < LevelParam.levels[a.getLevelNo() - 1].getStrLength(); i++) {
			char c = (char) (Math.random() * (127 - 33) + 33);// 输出随机字符
			str = str + c;
		}
		return str;// 返回
	}

	public void printResult(String out, String in, Player a) {
		long currentTime = System.currentTimeMillis();//
		if ((currentTime - a.getStartTime()) / 1000 > LevelParam.levels[a.getLevelNo() - 1].getTimeLimit()) {
			System.out.println("你输入的太慢了,已经超时,退出!");
			System.exit(1);// 程序结束
		} else if (out.equals(in)) {
			a.setCurrScore(a.getCurrScore() + LevelParam.levels[a.getLevelNo() - 1].getPerScore());// 积分累加
			System.out.println("输入正确,您的积分" + a.getCurrScore() + ",您的级别" + a.getLevelNo() + ",已用时间"
					+ (currentTime - a.getStartTime()) / 1000 + "秒");// 输出信息
		} else if (!out.equals(in)) {
			System.out.println("错误!退出.");
			System.exit(1);// 程序结束
		}
	}

}
